Learnerslesson
   JAVA   
  SPRING  
  SPRINGBOOT  
 HIBERNATE 
  HADOOP  
   HIVE   
   ALGORITHMS   
   PYTHON   
   GO   
   KOTLIN   
   C#   
   RUBY   
   C++   




count( ) FUNCTION


count( ) Function is used to specify the number of times an element is present in the Tuple.


Let us say, we have a Tuple that contains three names, 'Mohan', 'Kriti' and 'Salim'. And we want to find how many times 'Mohan' is present in the Tuple.


Example :


x = ("Mohan", "Kriti", "Mohan", "Salim")
y = x.count("Mohan")
print("The count of Mohan is ",y)


Output :



  The count of Mohan is 2

So, in the above code we have created a 'Tuple' and initialised to the variable 'x'.


x = ("Mohan", "Kriti", "Mohan", "Salim")

Below is how the values are positioned in the Tuple,


java_Collections

Now, if we see the above diagram, 'Mohan' is present '2' times in the above Tuple.


And the 'count( )' Function is used to find how many times 'Mohan' is present.


y = x.count("Mohan")

And we get the below output,


The count of Mohan is 2